<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MdiWin Demo - leftmenu</title>
    <uieip type="file" value="inc" src="/yqwin/easyui/include.txt" cache="true" minute="1440"></uieip>
    <uieip type="file" value="css" src="/yqwin/css/yqwin.min" cache="false"></uieip>
    <uieip type="file" value="js" src="/yqwin/data/yqwin.min" cache="false"></uieip>
</head>

<body>
    <h1>yq.topmenu</h1>
    <div id="mm1"></div>
    <div style="margin:20px 0;">
        <a href="#" class="easyui-linkbutton" onclick="btn1_disable()">Disable Edit</a>
        <a href="#" class="easyui-linkbutton" onclick="btn1_enable()">Enable Edit</a>
        <a href="#" class="easyui-linkbutton" onclick="btn1_destroy()">destroy</a>
    </div>

    <h1>yq.popmenu</h1>
    <div id="mm2"></div>

    <div style="margin:20px 0;">
        <a href="#" class="easyui-linkbutton" id="aa2">Open Pop</a>
        <a href="#" class="easyui-linkbutton" onclick="btn2_disable()">Disable Edit</a>
        <a href="#" class="easyui-linkbutton" onclick="btn2_enable()">Enable Edit</a>
        <a href="#" class="easyui-linkbutton" onclick="btn2_destroy()">destroy</a>
    </div>

    <h1>yq.editmenu</h1>
    <div id="mm3"></div>
    <div>
        <a href="#" class="easyui-linkbutton" id="aa3">Open Pop</a>
        <a href="#" class="easyui-linkbutton" onclick="btn3_disable()">Disable Edit</a>
        <a href="#" class="easyui-linkbutton" onclick="btn3_enable()">Enable Edit</a>
        <a href="#" class="easyui-linkbutton" onclick="btn3_destroy()">destroy</a>
    </div>
    <script>
        $(function () {
            initTopMenu();
        });

        var menus = [{
            id: "home",
            text: "Home",
            iconCls: "icon-search",
            onClick: function () {
                console.log("home click");
            }
        }, {}, {
            id: "m_title",
            text: "m-Title",
            iconCls: "icon-search",
            width: 180,     //宽度
            subs: [{
                id: "s1_title",
                text: "s1-Title",
                iconCls: "",

                onClick: function () {
                    console.log("s1-Title click");
                }
            }, {}, {
                id: "s2_title",
                text: "s2-Title",
                iconCls: "",
                onClick: function () {
                    console.log("s1_title click");
                }
            }, {
                id: "s3_title",
                text: "s3-Title",
                iconCls: "",
                width: 120,     //宽度 默认为150
                subs: [{
                    id: "s3_1_title",
                    text: "s3-1-Title",
                    iconCls: "",
                    onClick: function () {
                        console.log("s3-1-Title click");
                    }
                }]
            }],
        }, {
            id: "other",
            text: "其他",
            iconCls: "icon-search",
            subs: [{
                id: "isdel1",
                text: "注销",
                iconCls: "",
                onClick: function () {
                    console.log("s1-Title click");
                }
            }],
        },
        {
            id: "textbox",
            type: "textbox",
            width: 125,
            buttonText: 'Search',
            iconCls: 'icon-man',
            iconAlign: 'left',
            onClickButton: function () {
                console.log("ssssss");
            }
        },
        {
            id: "combobox",
            type: "combobox",
            width: 125,
            valueField: 'id',
            textField: 'text',
            data: [{
                "id": 1,
                "text": "text1"
            }, {
                "id": 2,
                "text": "text2"
            }],
            onChange: function (newValue, oldValue) {
                console.log("combobox", newValue);
            }
        }];

        function initTopMenu() {
            $("#mm1").yqTopMenu({
                menus: menus,
                afterBindingTitle: function () {
                    initPopMenu();
                },
            });
        }

        function btn1_disable() {
            $("#mm1").yqTopMenu("disable", "home");
            $("#mm1").yqTopMenu("disable", "s1_title");
            $("#mm1").yqTopMenu("hide", "s3_1_title");
        }

        function btn1_enable() {
            $("#mm1").yqTopMenu("enable", "home");
            $("#mm1").yqTopMenu("enable", "s1_title");
            $("#mm1").yqTopMenu("show", "s3_1_title");
        }

        function btn1_destroy() {
            $("#mm1").yqTopMenu("destroy");
        }

        function initPopMenu() {
            $("#mm2").yqPopMenu({
                menus: menus,
                bind: $("#aa2"),
                afterBindingTitle: function () {
                    //$("#mm2").yqPopMenu("bind", $("#aa2"));
                    initEditMenu();
                },
                beforeOpen: function (callback) {
                    callback(true)
                },
            });
        }

        function btn2_disable() {
            $("#mm2").yqPopMenu("disable", "home");
            $("#mm2").yqPopMenu("disable", "s1_title");
            $("#mm2").yqPopMenu("disable", "s3_1_title");
        }

        function btn2_enable() {
            $("#mm2").yqPopMenu("enable", "home");
            $("#mm2").yqPopMenu("enable", "s1_title");
            $("#mm2").yqPopMenu("enable", "s3_1_title");
        }

        function btn2_destroy() {
            $("#mm2").yqPopMenu("destroy");
        }

        function initEditMenu() {
            $("#mm3").yqEditMenu({
                type: 3,           //1(!=2或3)-顶部菜单，2-右键菜单，3-顶部+右键
                bind: $("#aa3"),   //右键菜单绑定的对象，jquery对象
                copy: true,
                addroot: true,
                add: true,
                upp: true,
                del: true,
                save: true,
                isdel: true,
                paste: true,
                move: true,
                links: [{
                    id: "add1",
                    text: "Add1",
                    iconCls: "icon2-copy",
                }, {
                    id: "add2",
                    text: "Add2",
                    iconCls: "icon2-copy",
                }],
                menus: [{
                    id: "add1-1",
                    text: "Add1-1",
                    iconCls: "icon2-copy",
                }, {
                    id: "add2-1",
                    text: "Add2-1",
                    iconCls: "icon2-copy",
                }],
                onClick: function (action) {
                    console.log(action);
                }
            });
        }

        function btn3_disable() {
            $("#mm3").yqEditMenu("disable", "add");
            $("#mm3").yqEditMenu("disable", "add1");
            $("#mm3").yqEditMenu("disable", "add2-1");
        }

        function btn3_enable() {
            $("#mm3").yqEditMenu("enable", "add");
            $("#mm3").yqEditMenu("enable", "add1");
            $("#mm3").yqEditMenu("enable", "add2-1");
        }

        function btn3_destroy() {
            $("#mm3").yqEditMenu("destroy");
        }
    </script>
</body>

</html>